#!/bin/bash

set -e
set -o pipefail
set -x

targets=($(find bsp -name settings.mk | cut -d '/' -f 2)) 

programs=($(ls software))

SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"

CONFIGURATION=debug

# Run regression tests
for target in ${targets[@]}
do
    for program in "${programs[@]}"
    do
        # Coremark and Dhrystone don't fit
        if [ "${program}" == "dhrystone" -o "${program}" == "coremark" -o "${program}" == "example-freertos-blinky-systemview" ] ; then
            continue
        fi

        make TARGET="${target}" PROGRAM="${program}" CONFIGURATION="${CONFIGURATION}" -j${nproc} software
        make TARGET="${target}" PROGRAM="${program}" CONFIGURATION="${CONFIGURATION}" clean-software
    done
    make TARGET="${target}" clean
done

echo "PASSED"

